<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head></head>
  <script type="text/javascript" src="Content/script/jquery-1.10.2.js"></script>
  <script>
  $(function(){
  	$(".delete").click(function(){
  		if(!confirm("确认删除吗？"))
  			return false;
  	});
  });

  </script>
  <style>
  div{width:600px}
  p{text-align:center}
  </style>
  <body>
	<div>
		电影分类：<select name="cid">
			<option value="0">全部</option>
			<c:forEach items="${categories }" var="c">
			<option values="${c.id }">${c.name }</option>
			</c:forEach>
			</select>
	电影名称：<input type="text" name="title"/>
	<p></p>
	<form action="EditMovieServlet" method="post">
		<table border="1">
	<thead>
		<tr>
			<td><a href="#">编辑</a></td>
			<td>电影名称</td>
			<td>编号</td>
			<td>分类</td>
			<td>导演</td>
			<td>上映时间</td>
			<td><input type="button" value="删除"/></td>
		</tr>
	</thead>
	<tbody>
	<c:forEach items="${movies }" var="m">
	<tr>
			<td><a href="EditMovieServlet?id=${m.id }">编辑</a></td>
			<td>${m.title }</td>
			<td>${m.movieCode }</td>
			<td>${m.category.name }</td>
			<td>${m.director }</td>
			<td>${m.dateReleased }</td>
			<td><a href="DeleteMovieServlet?id=${m.id }" class="delete"><input type="button" value="删除"/></a></td>
		</tr>
	</c:forEach>
	</tbody>
	</table>
	</form>
	<p>
	<c:if test="${pageNum > 1 }"> 
	<a href="MovieListServlet?pageNum=${pageNum-1 }">上一页</a>&nbsp;&nbsp;&nbsp;&nbsp;
	</c:if>
	

	<c:if test="${pageNum < totalPage }"> 
	<a href="MovieListServlet?pageNum=${ pageNum+1 }">下一页</a>
	</c:if>
	</p>
		<hr/>
	<a href="EditMovieServlet">添加新电影</a>
	</div>
  </body>
</html>
